<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:a="http://richfaces.org/a4j" template="/layout/template.xhtml">

	<ui:define name="body">

		<h:form id="courseAddStudent">

			<rich:panel>

				<h:panelGrid>
					<a:outputPanel id="req">
						<s:decorate id="studentSelect" template="/layout/edit.xhtml"
							rendered="#{courseHome.studentsToBeAdded.size==0}">
							<ui:define name="label">#{messages.addStudents}</ui:define>
							<rich:fileUpload fileUploadListener="#{courseHome.listener}"
								maxFilesQuantity="1" id="upload" immediateUpload="true"
								allowFlash="false" autoclear="false" ajaxSingle="true"
								listHeight="55">
								<a:support event="onuploadcomplete" reRender="info,req"
									ajaxSingle="true" />
							</rich:fileUpload>
						</s:decorate>
					</a:outputPanel>
				</h:panelGrid>
				<a:outputPanel id="info">
					<rich:dataTable rendered="#{courseHome.studentsToBeAdded.size!=0}"
						var="stud" value="#{courseHome.studentsToBeAdded}">
						<h:column>
							<f:facet name="header">#{messages.title}</f:facet>
							<h:outputText value="#{stud.username}" />
						</h:column>
						<h:column>
							<f:facet name="header">#{messages.detail}</f:facet>
							<h:outputText value="#{stud.nameToSrting()}" />
						</h:column>
						<h:column>
							<f:facet name="header">#{messages.dueDate}</f:facet>
							<h:outputText value="#{stud.dueDate}">
								<s:convertDateTime type="date" dateStyle="short"
									pattern="dd/MM/yyyy" />
							</h:outputText>
						</h:column>
					</rich:dataTable>
				</a:outputPanel>
			</rich:panel>




			<div class="actionButtons">
				<h:commandButton id="save" value="Save"
					action="#{courseHome.persist}" rendered="#{!courseHome.managed}" />
				<h:commandButton id="update" value="Save"
					action="#{courseHome.updateForBacthStudentList}"
					rendered="#{courseHome.managed}" />
				<s:button id="cancel" value="Cancel" view="/Course/course.xhtml" />
			</div>

		</h:form>

	</ui:define>

</ui:composition>